package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.Noxianxing;
import com.ruoyi.system.service.INoxianxingService;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;

/**
 * 不限行规则 信息操作处理
 * 
 * @author ruoyi
 * @date 2019-07-30
 */
@Controller
@RequestMapping("/system/noxianxing")
public class NoxianxingController extends BaseController
{
    private String prefix = "system/noxianxing";
	
	@Autowired
	private INoxianxingService noxianxingService;
	
	@RequiresPermissions("system:noxianxing:view")
	@GetMapping()
	public String noxianxing()
	{
	    return prefix + "/noxianxing";
	}
	
	/**
	 * 查询不限行规则列表
	 */
	@RequiresPermissions("system:noxianxing:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(Noxianxing noxianxing)
	{
		startPage();
        List<Noxianxing> list = noxianxingService.selectNoxianxingList(noxianxing);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出不限行规则列表
	 */
	@RequiresPermissions("system:noxianxing:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(Noxianxing noxianxing)
    {
    	List<Noxianxing> list = noxianxingService.selectNoxianxingList(noxianxing);
        ExcelUtil<Noxianxing> util = new ExcelUtil<Noxianxing>(Noxianxing.class);
        return util.exportExcel(list, "noxianxing");
    }
	
	/**
	 * 新增不限行规则
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存不限行规则
	 */
	@RequiresPermissions("system:noxianxing:add")
	@Log(title = "不限行规则", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(Noxianxing noxianxing)
	{		
		return toAjax(noxianxingService.insertNoxianxing(noxianxing));
	}

	/**
	 * 修改不限行规则
	 */
	@GetMapping("/edit/{noxianxingId}")
	public String edit(@PathVariable("noxianxingId") Integer noxianxingId, ModelMap mmap)
	{
		Noxianxing noxianxing = noxianxingService.selectNoxianxingById(noxianxingId);
		mmap.put("noxianxing", noxianxing);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存不限行规则
	 */
	@RequiresPermissions("system:noxianxing:edit")
	@Log(title = "不限行规则", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(Noxianxing noxianxing)
	{		
		return toAjax(noxianxingService.updateNoxianxing(noxianxing));
	}
	
	/**
	 * 删除不限行规则
	 */
	@RequiresPermissions("system:noxianxing:remove")
	@Log(title = "不限行规则", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(noxianxingService.deleteNoxianxingByIds(ids));
	}
	
}
